//
//  SSSetupMineInfoViewController.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/2/9.
//

import UIKit

class SSSetupMineInfoViewController: UITableViewController {
    
    @IBOutlet weak var userNameLab: UILabel!
    var user = SSUser()
    
    @IBOutlet weak var emailLab: UILabel!
    @IBOutlet weak var sertupDescribeLab: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "我的"
        
        tableView?.separatorStyle = .none
        userNameLab.text = user.userName
        
        setupEmail()
        
    }
    
    func setupEmail() {
        if user.email.count > 0 {
            emailLab.isHidden = false
            emailLab.text = user.email
            sertupDescribeLab.isHidden = true
        }
    }
    

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        if (indexPath.row == 2){
            let vc = SSModifyEmailViewController.init(nibName: "SSModifyEmailViewController", bundle: nil)
            vc.user = self.user
            vc.modifyEmailResult { email in
                self.user.email = email
                self.setupEmail()
            }
            navigationController?.pushViewController(vc, animated: true)
        }
    }
  

}
